package com.platform.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.platform.dao.ApiWarmClassRecordMapper;
import com.platform.entity.WarmClassRecordVo;

/**
 * 暖课购买记录Service实现类
 *
 * @author czj
 * @email 729618941@qq.com
 * @date 2018-11-01 16:50:06
 */
@Service
public class ApiWarmClassRecordService {
    @Autowired
    private ApiWarmClassRecordMapper warmClassRecordDao;


    public WarmClassRecordVo queryObject(Integer id) {
        return warmClassRecordDao.queryObject(id);
    }


    public List<WarmClassRecordVo> queryList(Map<String, Object> map) {
        return warmClassRecordDao.queryList(map);
    }


    public int queryTotal(Map<String, Object> map) {
        return warmClassRecordDao.queryTotal(map);
    }


    public int save(WarmClassRecordVo warmClassRecord) {
        return warmClassRecordDao.save(warmClassRecord);
    }


    public int update(WarmClassRecordVo warmClassRecord) {
        return warmClassRecordDao.update(warmClassRecord);
    }


    public int delete(Integer id) {
        return warmClassRecordDao.delete(id);
    }


    public int deleteBatch(Integer[] ids) {
        return warmClassRecordDao.deleteBatch(ids);
    }


    /**
     * 是否已支付该课程
     */
    public Boolean isPay(Integer id, Long userId) {
        Map<String, Object> params = new HashMap<>();
        params.put("userId", userId);
        params.put("warmClassId", id);
        params.put("isPay", 1);//已支付

        int i = queryTotal(params);
        if (i == 0) {
            return false;
        }

        return true;
    }
}
